package cn.cool.controller;


import cn.cool.entity.UserFollow;
import cn.cool.service.UserFollowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LiuH
 * @since 2021-01-23
 */
@RestController
@RequestMapping("/userFollow")
@Api(tags = "用户关注/粉丝接口")
public class UserFollowController {

    @Autowired
    private UserFollowService userFollowService;

    @PostMapping("/setUserFollow")
    @ApiOperation(value = "用户关注")
    public Object setUserFollow(HttpServletRequest request,Integer followId){
        Object result = userFollowService.setUserFollow(request, followId);
        return result;
    }

    @GetMapping("/getUserFollow")
    @ApiOperation(value = "查看目标用户或当前用户的关注列表")
    public Object getUserFollow(HttpServletRequest request,@RequestParam(required = false) Integer targetId){
        Object result = userFollowService.getUserOrTargerFollow(request, targetId);
        return result;
    }

    @GetMapping("/getUserFans")
    @ApiOperation(value = "查看目标用户或当前用户的关注列表")
    public Object getUserFans(HttpServletRequest request,@RequestParam(required = false) Integer targetId){
        Object result = userFollowService.getUserOrTargerFans(request, targetId);
        return result;
    }

    @GetMapping("/getMutualFollow")
    @ApiOperation(value = "获取当前用户与目标用户的共同关注")
    public Object getMutualFollow(HttpServletRequest request,Integer targetId){
        Object mutualFollow = userFollowService.getMutualFollow(request, targetId);
        return mutualFollow;
    }

}

